using HTCollections.Unsafe;
using Unity.Burst;
using Unity.Jobs;
using Unity.Mathematics;

namespace HTCollections.Job
{
    [BurstCompile]
    public unsafe struct KdTreeBuildJob : IJob
    {
        public JobDataWrap<UnsafeKdTree2D> KdTree;
        public JobDataWrap<UnsafeList<float3>> Points;

        public void Execute()
        {
            var kdTree = KdTree.Value;
            var points = Points.Value;
            kdTree.Build(points.Ptr, points.Length);

            //struct 必须重新赋值
            KdTree.Value = kdTree;
            Points.Value = points;
        }
    }
}